﻿//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Linq;

using ProjectBase.Core;
using ProjectBase.Core.Web;

namespace Survey.Web.Controls
{
    public abstract class MenuContent<TModel> : RazorControl<TModel>
        where TModel : class, ICoreModel
    {
        protected const string MenuItemName = "aside_";
        protected const string CookiePrefix = "menu_";
        protected const string SettingName = "selected";
        protected const string NotSelectedTab = "notSelectedTab";

        protected virtual string SelectedTab(int index)
        {
            var tab = Context.Request.Cookies[CookiePrefix + MenuItemName + SettingName];
            if (tab.Is()
                && tab.Value.IsNotEmpty())
            {
                return tab.Value.Equals(index.ToString())
                           ? string.Empty
                           : NotSelectedTab;
            }
            return index == 0
                       ? string.Empty
                       : NotSelectedTab;
        }
    }
}